<template>
    <div class="newsMain">
        <div class="start">
            <h2>新闻中心</h2>
            <div class="lineHei"></div>
            <p>记录团队成长点滴以及对技术、理念的探索，同时我们乐于分享！</p>
        </div>
        <div class="nav_news"  >
            <a href="javascript:void(0)" @click="clickNews(1)" :class="{onchange:changed===1}">公司新闻</a>
            <a href="javascript:void(0)" @click="clickNews(0)" :class="{onchange:changed===0}">行业新闻</a>
        </div>

        <div class="knowMain">
            <div class="knowCard" v-for="(item,index) in newsData" :key="index">
                <img :src="item.imgUrl" alt="">
                <div class="textCard">
                    <div class="title">
                        <span class="type">{{item.type}}</span>
                        <span class="titleMain" :title="item.title"><a :href="item.link" @click="transfer">{{item.title}}</a></span>
                    </div>
                    <p class="tags">{{item.tagTime}} <i>查看</i>({{item.tagNum}})</p>
                    <p CLASS="textMain">{{item.textOne}}</p>
                </div>
            </div>
            <div class="num">
                <span>共<b>1</b>页<b>{{newsNum}}</b>条记录</span>
            </div>
        </div>
		<!-- 问题表单 -->
        <question-ask/>
    </div>
</template>

<script>
    import bus from "../../util/bus";
    import cont from "../../util/cont";
    export default {
        name: "newsMain",
        components:{
            questionAsk:()=>import('../../components/question/question')
        },
        data(){
            return{
                finallyData:cont,
                newsData:[],
                newsNum:0,
                changed:1,
            }
        },
        created() {
            var id=parseInt(this.$route.params["id"]);
            this.clickNews(id)
        },
        methods:{
            clickNews(id){
                var test=[];
                if(id){
                    test.push(this.finallyData.slice(0,2));
                    this.newsData=test["0"];
                    this.newsNum=this.newsData.length;
                }else {
                    test.push(this.finallyData.slice(2));
                    this.newsData=test["0"];
                    this.newsNum=this.newsData.length;
                }
                this.changed=id;
            },
            transfer(){
                // bus.$emit("transferData",this.finallyData);
            }
        }

    }
</script>

<style lang="less" scoped>
    .newsMain{
        box-sizing: border-box;
        min-width: 1400px;
        width: 100%;
        .start{
            height: 400px;
            padding: 150px 170px;
            box-sizing: border-box;
            background: url("../../assets/news/h-top-1.jpg") no-repeat;
            background-size: 100% 100%;
            h2{
                font-size: 30px;
                font-weight: 500;
                color: white;
                margin-bottom: 15px;
            }
            .lineHei{
                height: 2px;
                width: 80px;
                background: #0595C7;
            }
            p{
                font-size: 15px;
                color: white;
                opacity: .8;

            }
        }
        .nav_news{
            width: 200px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            height: 70px;
            margin: 0 auto;
            a{
                /*height: 70px;*/
                height: 35px;
                display: block;
                line-height: 35px;
                color: #666666;
                width: 80px;
                text-align: center;
                transition: .3s ease-in-out;
                &:hover{
                    background: #0595C7 !important;
                    color: white !important;
                }

            }
        }
        .knowMain{
            background: #F1F1F1;
            width: 100%;
            min-width: 1400px;
            box-sizing: border-box;
            padding: 20px 270px;
            .knowCard{
                border-bottom: 1px solid #cccccc;
                padding: 15px 15px;
                height: 200px;
                width: 100%;
                background: white;
                overflow: auto;
                img{
                    float: left;
                    height: 170px;
                    width: 300px;
                }
                .textCard{
                    float: left;
                    width: 60%;
                    margin-left: 40px;
                    box-sizing: border-box;
                    padding-top: 40px;
                    /*min-width: 500px;*/
                    /*display: flex;?*/
                    /*align-items: center;*/
                    .type{
                        margin-right: 15px;
                        background: #0595C7;
                        color: white;
                        display: block;
                        font-size: 13px;
                        float: left;
                        height: 25px;
                        line-height: 25px;
                        width: 70px;
                        text-align: center;
                    }
                    .titleMain{
                        float: left;
                        font-size: 18px;
                        display: block;
                        height: 25px;
                        line-height: 25px;
                        cursor: pointer;
                        a{
                            color: #666666;
                            &:hover{
                                color: #0595C7;
                            }
                        }


                    }
                    .tags{
                        display: block;
                        font-size: 12px;
                        color: #cccccc;
                        width: 300px;
                        margin-top: 30px;
                        margin-bottom: 0;
                        line-height: 40px;
                    }
                    .textMain{
                        font-size: 13px;
                        float: left;
                        color: #aaaaaa;
                        margin-top: 0;

                    }
                }

            }
            .num{
                padding: 30px 0;
                height: 30px;
                span{
                    display: block;
                    width: 100px;
                    height: 25px;
                    line-height: 25px;
                    background: white;
                    font-size: 13px;
                    color: #aaaaaa;
                    margin: 0 auto;
                    text-align: center;
                    border: 1px solid #cccccc;
                }

            }
        }
    }
    .onchange{
        background: #0595C7 !important;
        color: white !important;
    }

</style>
